/* 假币问题 */

#include<iostream>
#include<cstring>
using namespace std;


int CalcWeight(const char *strCoin, const int *weight)
{
	const char *p = strCoin;
	int resWeight = 0;

	for (; *p != '\0'; ++p)
	{
		resWeight += weight[*p - 'A'];
	}

	return resWeight;
}

bool IsBalanced(const char *left, const char *right, const int *weight, const char *strBalanced)
{
	int leftWeight = CalcWeight(left, weight);
	int rightWeight = CalcWeight(right, weight);

	if (leftWeight < rightWeight && strcmp(strBalanced, "down") == 0)
	{
		return true;
	}
	else if (leftWeight == rightWeight && strcmp(strBalanced, "even") == 0)
	{
		return true;
	}
	else if (leftWeight > rightWeight && strcmp(strBalanced, "up") == 0)
	{
		return true;
	}

	return false;
}

int main(void)
{
	int nCases = 1;
	const char* strCases[] = {
		"ABCD", "EFGH", "even",
		"ABCI", "EFJK", "up",
		"ABIJ", "EFGH", "even"
	};

	for (int nc = 0; nc < nCases; nc++)
	{
		int weight[12] = {0};
		const char **strCurCase = &strCases[9 * nc];

		for(int i = 0; i < 12; i++)
		{
			weight[i] = -1;
			if (IsBalanced(strCurCase[0], strCurCase[1], weight, strCurCase[2])
			&& IsBalanced(strCurCase[3], strCurCase[4], weight, strCurCase[5])
			&& IsBalanced(strCurCase[6], strCurCase[7], weight, strCurCase[8]))
			{
				cout<< (char)('A' + i) << " is light.\n";
				break;
			}

			weight[i] = 1;
			if (IsBalanced(strCurCase[0], strCurCase[1], weight, strCurCase[2])
			&& IsBalanced(strCurCase[3], strCurCase[4], weight, strCurCase[5])
			&& IsBalanced(strCurCase[6], strCurCase[7], weight, strCurCase[8]))
			{
				cout<< (char)('A' + i) << " is weight.\n";
				break;
			}
			
			weight[i] = 0;
		}
	}
}
